class Solution(object):
    def longestConsecutive(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        nums_set = set(nums)
        max_value = 0
        for num in nums_set:
            if num - 1 not in nums_set:
                now_value = 1
                judge_num = num + 1
                while judge_num in nums_set:
                    now_value += 1
                    judge_num += 1
                max_value = max(max_value, now_value)
        return max_value


data = Solution()
nums = [100,4,200,1,3,2]
print(data.longestConsecutive(nums))
